﻿using MODEL;
using SysHelper;
using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SysController
{
    public static partial class SystemController
    {
    //    #region 1.0 查询系统信息 + static List<AuthorizedInfoConfig> GetAccountInfo(AuthorizedInfoConfig AccountModel)
    //    /// <summary>
    //    /// 1.0 查询系统信息
    //    /// </summary>
    //    /// <param name="AccountModel"></param>
    //    /// <returns></returns>
    //    public static List<AuthorizedInfoConfig> GetAccountInfo(AuthorizedInfoConfig AccountModel)
    //    {
    //        return OperateContext.CurrentContext.BllSession.IAuthorizedInfoConfig_BLL.GetListByWhere(s => s.SalesPlatformId == AccountModel.SalesPlatformId && s.SalesPlatformName == AccountModel.SalesPlatformName);
    //    }
    //    #endregion

    //    #region 1.1 修改AccessToken + static int SaveAccessToken(AuthorizedInfoConfig config)
    //    /// <summary>
    //    /// 修改AccessToken
    //    /// </summary>
    //    /// <param name="config"></param>
    //    /// <returns></returns>
    //    public static int ModifyAccessToken(AuthorizedInfoConfig config)
    //    {
    //        OperateContext.CurrentContext.BllSession.IAuthorizedInfoConfig_BLL.Modify(config, s => s.SalesPlatformName == config.SalesPlatformName && s.SiteInfoName == config.SiteInfoName && s.LoginAccount == config.LoginAccount, "AccessToken", "Timestamp");
    //        return OperateContext.CurrentContext.BllSession.SaveChanges(typeof(AuthorizedInfoConfig).Name);
    //    }
    //    #endregion

    //    #region 1.2 品类修改增加 + static int CategoryDH(List<CategoryPublish> list)
    //    /// <summary>
    //    /// 1.2 品类修改增加
    //    /// </summary>
    //    /// <param name="list"></param>
    //    /// <returns></returns>
    //    public static int CategoryDH(List<CategoryPublish> list)
    //    {
    //        foreach (var item in list)
    //        {
    //            OperateContext.CurrentContext.BllSession.ICategoryPublish_BLL.ModifyIsNullADD(item, s => s.catePubId == item.catePubId, true);
    //        }
    //        return OperateContext.CurrentContext.BllSession.SaveChanges(typeof(CategoryPublish).Name);
    //    }
    //    #endregion

    //    #region 1.3 单位列表信息 + static int MeasureDH(List<Measure> list)
    //    /// <summary>
    //    /// 单位列表信息
    //    /// </summary>
    //    /// <param name="list"></param>
    //    /// <returns></returns>
    //    public static int MeasureDH(List<Measure> list)
    //    {
    //        foreach (var ls in list)
    //        {
    //            OperateContext.CurrentContext.BllSession.IMeasure_BLL.ModifyIsNullADD(ls, s => s.MeasureCode == ls.MeasureCode, true);
    //        }
    //        return OperateContext.CurrentContext.BllSession.SaveChanges(typeof(Measure).Name);
    //    }
    //    #endregion

    //    #region 1.4 品类属性及属性值 + static int CategoryArrVal(List<CategoryAttribute> lsAttr, List<AttributeValue> lsVal)
    //    /// <summary>
    //    /// 品类属性及属性值
    //    /// </summary>
    //    /// <param name="lsAttr"></param>
    //    /// <param name="lsVal"></param>
    //    /// <returns></returns>
    //    public static int CategoryArrVal(List<CategoryAttribute> lsAttr, List<AttributeValue> lsVal)
    //    {
    //        foreach (var ls in lsAttr)
    //        {
    //            OperateContext.CurrentContext.BllSession.ICategoryAttribute_BLL.ModifyIsNullADD(ls, s => s.catePubId == ls.catePubId && s.catePubAttrId == ls.catePubAttrId, true);
    //        }
    //        foreach (var ls in lsVal)
    //        {
    //            OperateContext.CurrentContext.BllSession.IAttributeValue_BLL.ModifyIsNullADD(ls, s => s.catePubAttrId == ls.catePubAttrId && s.catePubAttrvalId == ls.catePubAttrvalId, true);
    //        }
    //        int Res = 0;
    //        Res = OperateContext.CurrentContext.BllSession.SaveChanges(typeof(CategoryAttribute).Name);
    //        Res += OperateContext.CurrentContext.BllSession.SaveChanges(typeof(AttributeValue).Name);
    //        return Res;
    //    }
    //    #endregion

    //    #region 1.5 产品组 +static int ProductGroups(List<ProductGroup> lsProductGroup)
    //    /// <summary>
    //    /// 产品组
    //    /// </summary>
    //    /// <param name="lsProductGroup"></param>
    //    /// <returns></returns>
    //    public static int ProductGroups(List<ProductGroup> lsProductGroup)
    //    {
    //        foreach (var ls in lsProductGroup)
    //        {
    //            OperateContext.CurrentContext.BllSession.IProductGroup_BLL.ModifyIsNullADD(ls, s => s.groupId == ls.groupId, true);
    //        }
    //        return OperateContext.CurrentContext.BllSession.SaveChanges(typeof(ProductGroup).Name);
    //    }
    //    #endregion

    //    public static int ShippingTemplate(List<ShippingTemplate> lsShippingTemplate)
    //    {
    //        foreach (var ls in lsShippingTemplate)
    //        {
    //            OperateContext.CurrentContext.BllSession.IShippingTemplate_BLL.ModifyIsNullADD(ls, s => s.AccountName == ls.AccountName && s.ShippingModelId == ls.ShippingModelId && s.SupplierId == ls.SupplierId, true);
    //        }
    //        return OperateContext.CurrentContext.BllSession.SaveChanges(typeof(ShippingTemplate).Name);
    //    }
    //    public static List<CategoryPublish> QueryCategory(string catePubId)
    //    {
    //        if (catePubId == null)
    //            return OperateContext.CurrentContext.BllSession.ICategoryPublish_BLL.GetListByWhere(s => s.IsDel == false);
    //        else
    //            return OperateContext.CurrentContext.BllSession.ICategoryPublish_BLL.GetListByWhere(s => s.IsDel == false && s.catePubId == catePubId);
    //    }

    //    public static List<CategoryAttribute> QueryCategoryAttr(string catePubId)
    //    {
    //        return OperateContext.CurrentContext.BllSession.ICategoryAttribute_BLL.GetListByWhere(s => s.IsDel == false && s.catePubId == catePubId);
    //    }

    //    public static List<AttributeValue> QueryAttrbuteVal(int catePubAttrId)
    //    {
    //        return OperateContext.CurrentContext.BllSession.IAttributeValue_BLL.GetListByWhere(s => s.IsDel == false && s.catePubAttrId == catePubAttrId);
    //    }

    //    public static List<ProductCategoryAttrVal> QueryCategoryAttrbuteVal(string codelist)
    //    {
    //        return OperateContext.CurrentContext.BllSession.IProductCategoryAttrVal_BLL.GetListByWhere(s => s.Code == codelist);
    //    }

    //    public static List<ProductImageDH> QueryProductImage(string codelist)
    //    {
    //        return OperateContext.CurrentContext.BllSession.IProductImageDH_BLL.GetListByWhere(s => s.Code == codelist);
    //    }

    //    //public static List<PuTable> QueryProductBaseInfo(string codelist)
    //    //{
    //    //    return OperateContext.CurrentContext.BllSession.IPuTable_BLL.GetListByWhere(s => s.sku == codelist);

    //    //}

    //}

    //public static partial class SystemController
    //{
    //    public static List<SalesPlatform> LoadSalesPlatform(int salesPlatformId = -1)
    //    {
    //        return OperateContext.CurrentContext.BllSession.ISalesPlatform_BLL.GetListByWhere(s => s.IsDel == false && (salesPlatformId == -1 || s.SalesPlatformID == salesPlatformId));
    //    }

    //    public static List<SiteInfo> LoadSiteInfo(int siteInfoId = -1)
    //    {
    //        return OperateContext.CurrentContext.BllSession.ISiteInfo_BLL.GetListByWhere(s => s.IsDel == false && (siteInfoId == -1 || s.SiteInfoID == siteInfoId));
    //    }

    //    public static List<SellerAccountInfo> LoadSellerAccountInfo(int sellerAccountInfoId = -1)
    //    {
    //        return OperateContext.CurrentContext.BllSession.ISellerAccountInfo_BLL.GetListByWhere(s => s.IsDel == false && (sellerAccountInfoId == -1 || s.SellerAccountInfoID == sellerAccountInfoId));
    //    }

    //    public static List<LanguageType> LoadLanguageType(int languageTypeId = -1)
    //    {
    //        return OperateContext.CurrentContext.BllSession.ILanguageType_BLL.GetListByWhere(s => s.IsDel == false && (languageTypeId == -1 || s.LanguageTypeID == languageTypeId));
    //    }

    //    public static List<ProductStatu> LoadProductStatu(int productStatuId = -1)
    //    {
    //        return OperateContext.CurrentContext.BllSession.IProductStatu_BLL.GetListByWhere(s => s.IsDel == false && (productStatuId == -1 || s.ProductStatusId == productStatuId));
    //    }

    //    public static List<Category> LoadCategory(int categoryId = -1, int pid = -1)
    //    {
    //        return OperateContext.CurrentContext.BllSession.ICategory_BLL.GetListByWhere(s => s.IsDel == false && (categoryId == -1 || s.CategoryID == categoryId) && (pid == -1 || s.ID == pid));
    //    }

    //    public static List<UP_SalesPlatformSiteAccount_Result> LoadSalesPlatformSiteAccount_Result()
    //    {
    //        return OperateContext.CurrentContext.BllSession.IAlbum_BLL.ExecProcedure<UP_SalesPlatformSiteAccount_Result>("UP_SalesPlatformSiteAccount");
    //    }

    //    public static List<Contraband> LoadContraband()
    //    {
    //        return OperateContext.CurrentContext.BllSession.IContraband_BLL.GetListByWhere(s => s.IsDel == false);
    //    }

    //    public static List<LanguageType> LoadLanguageType()
    //    {
    //        return OperateContext.CurrentContext.BllSession.ILanguageType_BLL.GetListByWhere(s => s.IsDel == false);
    //    }

    //    public static List<UP_GetTemplate_Result> GetTemplate(int? SalesPlatformSiteSellerAccountInfoID)
    //    {
    //        var salesPlatformSiteSellerAccountInfoIDParameter = SalesPlatformSiteSellerAccountInfoID.HasValue ?
    //               new ObjectParameter("SalesPlatformSiteSellerAccountInfoID", SalesPlatformSiteSellerAccountInfoID) :
    //               new ObjectParameter("SalesPlatformSiteSellerAccountInfoID", typeof(int));

    //        return OperateContext.CurrentContext.BllSession.ISalesPlatformSiteSellerAccountInfoTemplateWebPageTemplateTerm_BLL.ExecProcedure<UP_GetTemplate_Result>("UP_GetTemplate", salesPlatformSiteSellerAccountInfoIDParameter);
    //    }

    //    public static List<SalesPlatformSiteInfoCategory> LoadSalesPlatformSiteInfoCategory(int SalesPlatformSiteInfoID)
    //    {
    //       return  OperateContext.CurrentContext.BllSession.ISalesPlatformSiteInfoCategory_BLL.GetListByWhere(s => s.IsDel == false && s.SalesPlatformSiteInfoID == SalesPlatformSiteInfoID);
    //    }

    //    public static List<SalesPlatformSiteInfoCategorySpecific> LoadSalesPlatformSiteInfoCategorySpecific(int SalesPlatformSiteInfoID, int SalesPlatformSiteInfoCategoryID)
    //    {
    //       return OperateContext.CurrentContext.BllSession.ISalesPlatformSiteInfoCategorySpecific_BLL.GetListByWhere(s => s.IsDel == false && s.SalesPlatformSiteInfoID == SalesPlatformSiteInfoID && s.SalesPlatformSiteInfoCategoryID == SalesPlatformSiteInfoCategoryID);
    //    }
    //}

    //public static partial class SystemController
    //{
    //    public static int AddContraband(Contraband model)
    //    {
    //        OperateContext.CurrentContext.BllSession.IContraband_BLL.ADD(model);
    //       return  OperateContext.CurrentContext.BllSession.SaveChanges(typeof(Contraband).Name);
    //    }

    //    public static int SaveProductContraband(ProductConfig model)
    //    {
    //        OperateContext.CurrentContext.BllSession.IProductConfig_BLL.ModifyIsNullADD(model, s => s.Code == model.Code, true);
    //     return    OperateContext.CurrentContext.BllSession.SaveChanges(typeof(ProductConfig).Name);
    //    }


    }

}
